don't break when stderr is used#3
Open
jomo wants to merge 1 commit into
Open
Conversation
df using stderr does not mean the command failed. for example, on heroku, using `df` fails: ```shell $ df; echo $? df: cannot read table of mounted file systems: No such file or directory 1 ``` but using `df /app` works with a warning: ```shell $ df /app; echo $? df: Warning: cannot read table of mounted file systems: No such file or directory Filesystem 1K-blocks Used Available Use% Mounted on - 12345 123 1234 123% /app 0 ``` This change first checks if there is an error, and then sets the error's message to whatever stderr is. It will always call back with the error or stderr only, and with the parsed info from stdout. However, it will always try to parse, even if stderr is used or an error occured That makes it possible to use node-df on systems like heroku where df prints warnings to stderr, but works anyway
Author
|
I think I forgot something, don't merge this yet :P 💩 |
Author
|
nvm, works exactly as intended 😎 df({}, function(err, result) {
console.error("Error", err);
console.log(result);
});
//=> error { [Error: df: cannot read table of mounted file systems: No such file or directory
// ] killed: false, code: 1, signal: null, cmd: '/bin/sh -c df -kP' }
//=> undefineddf({file: "/app"/}, function(err, result) {
console.error("Error", err);
console.log(result);
});
//=> error df: Warning: cannot read table of mounted file systems: No such file or directory
//=> [ { filesystem: '-',
// size: 12345,
// used: 123,
// available: 1234,
// capacity: 123,
// mount: '/app' } ] |
jomo
added a commit
to crafatar/crafatar
that referenced
this pull request
Aug 30, 2015
until adriano-di-giovanni/node-df#3 is merged fixes #4
Owner
|
Hi @jomo, Can you tell me about line 21 if (error) { error.message = stderr; }I think that |
Author
|
You're right. |
Owner
|
I mean, you can have |
Author
|
Yes, that's where callback(error || stderr, response);kicks in. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dfprinting to stderr does not mean the command failed.for example, on heroku, using
dffails:but using
df /appworks with a warning:This change first checks if there is an error, and then sets the error's message to whatever stderr is.
It will always call back with the error or stderr only, and with the parsed info from stdout.
However, it will always try to parse, even if stderr is used or an error occured
That makes it possible to use node-df on systems like heroku where df prints warnings to stderr, but works anyway